home *** CD-ROM | disk | FTP | other *** search
/ Mac Format 1996 April / MacFormat CD Edition MF36 (April 1996).iso / Shareware City / Developers / Tools Plus - GUI⁄Event libs / Tools Plus 2.6.1a Evaluat'n Kit / Tools Plus 2.6.1a / User Manual / 23-Completing Your Application < prev    next >
INI File  |  1995-04-01  |  28KB  |  402 lines

  1. [Display using Monaco 9]
  2.  
  3.  
  4. 23  Completing Your Application
  5. ```````````````````````````````
  6.  
  7.   This section details the final steps that you must take to produce a stand-alone, double-clickable application.  The requirements for an application using Tools Plus libraries are nearly identical to those of ordinary Macintosh applications, except that the SIZE resource has some very specific needs.  It is assumed that by the time you address these concerns, you have already written and debugged an application within your development environment and that you are ready to make it a stand-alone application.
  8.  
  9.   All the work encompassed in this section requires that you use a resource editor such as Apple’s ResEdit to create and/or modify resources.  The Symantec and Metrowerks development environments allow you to use a resource file as part of your project.  That resource file is automatically merged into your compiled code when you build your project.  Therefore we recommend you create and save these resources in a separate resource file and allow your development environment to merge them with your application (instead of manually adding them to your compiled application).
  10.  
  11.   Completing your application involves making some decisions, then creating the appropriate resources.  The table below summarizes the various tasks and their significance to your final application.
  12.  
  13.  
  14. ===============================+========================================
  15. Task (section in this chapter) | Significance to your application
  16. ===============================+========================================
  17. Application Icons              | Defines the icons that are displayed by
  18. File Types, Creators, and the  | the Finder for your application and the
  19.    Application Signature       | files it creates.
  20. Bundle (BNDL resource)         | 
  21. -------------------------------+----------------------------------------
  22. Version (vers resource)        | For displaying a version number in your
  23.                                | application’s “Get Info” box.  An
  24.                                | application description can also be
  25.                                | displayed. (Optional)
  26. -------------------------------+----------------------------------------
  27. mstr resource                  | Remapping of the File menu’s “Quit”
  28.                                | item and the File menu’s “Open…” item
  29.                                | to another menu and/or menu item.
  30.                                |    The “Quit”  command is automatically
  31.                                | invoked when your application is
  32.                                | running and the user selects the
  33.                                | Special menu’s Restart or Shut Down
  34.                                | commands.
  35.                                |    The “Open…” command is automatically
  36.                                | invoked when your application is
  37.                                | running and the user double-clicks
  38.                                | (opens) a document created by your
  39.                                | application.
  40.                                |    If your application does not have
  41.                                | the “Open…” or “Quit” items in a “File”
  42.                                | menu, and your application will [i] run
  43.                                | on Macs with System 5 or 6, or [ii] not
  44.                                | process high-level events, you need to
  45.                                | add mstr resources. (Optional)
  46. -------------------------------+----------------------------------------
  47. SIZE resource                  | Defines your application’s behavior and
  48.                                | memory requirements in a multi-
  49.                                | tasking environment.  Needed for
  50.                                | MultiFinder and System 7.
  51. -------------------------------+----------------------------------------
  52.  
  53.  
  54.  
  55.  
  56. Application’s Icons
  57. ```````````````````
  58.   The Macintosh’s Finder displays an application and its related files as icons.  In order for the Finder to do this, it needs to know what each icon looks like.  Without this information, your application will have the “generic application” icon (diamond with a hand holding a pen) and its related files will have the “generic document” icon (blank page with corner folded down).
  59.  
  60.   At the very least, you will need to create a large (32x32 bit) black and white icon (ICN#) for your application, and one for each type of document it creates.  You should also consider creating equivalent small (16x16 bit) black and white icons (ics#), because the Finder displays these miniatures when a disk’s or folder’s view is set to “small icon,” or when System 7 displays lists with icons.
  61.  
  62.   System 7 can display your application’s icons in color, so you can optionally include color icons as equivalents for the black and white ones.  The icl8 and icl4 icon types are large icons using 8 bits (256 colors) and 4 bits (16 colors) respectively.  Small color icons can also be created as ics8 and ics4 type icons.  Later, the “bundle” describes how to integrate the icon resources into your finished application.
  63.  
  64.  
  65.  
  66.  
  67.  
  68. Icon Family
  69. ```````````
  70.   When a specific icon ID number is shared by two or more icon types, those related icons are called an “icon family.”  The icon family with an ID of 128 is usually the icon that depicts your application.  Your application’s document icons would likely be numbered 129 and up.  When you create icons, remember to use ID numbers 128 or higher.  The rest are reserved numbers.
  71.  
  72. Note: When creating icl8 and ics8 icons with ResEdit, you have a choice
  73.       of two color palettes: “Apple icon colors” or “Standard 256
  74.       colors.”  Use the Apple icon colors, since they will guarantee
  75.       that your icon can be selected (darkened) properly.
  76.  
  77.  
  78.  
  79.  
  80.  
  81. File Types, Creators, and the Application Signature
  82. ```````````````````````````````````````````````````
  83.   On the Macintosh, all files (including application, desk accessories, documents, etc.) have a file type and a creator code.  Both of these items are always four characters long, allowing any visible or invisible characters and spaces.  The file type tells the Macintosh what the file contains.  Your application will always have a file type of ‘APPL.’  You can define your own file types for the documents created by your application if they don’t fit into any of the existing general types as follows:
  84.  
  85.     APPL    Launchable application
  86.     DFIL    File for sorting DAs
  87.     DRVR    Driver
  88.     FFIL    File for sorting fonts
  89.     INIT    System extension
  90.     PICT    QuickDraw picture
  91.     PRER    Printer driver
  92.     RDEV    Chooser extension
  93.     TEXT    Stream of ASCII characters
  94.     adev    Network extension
  95.     appe    Background-only application
  96.     cdev    Control panel
  97.     edtp    Edition for sharing graphics
  98.     edts    Edition for sharing sound
  99.     edtt    Edition for sharing text
  100.     ffil    Font
  101.     ifil    Script system resources
  102.     kfil    Keyboard layout
  103.     pref    Preferences file
  104.     qery    Query document (databases)
  105.     scri    System extension for scripting
  106.     sfil    Sound
  107.     tfil    TrueType font
  108.     ttro    TeachText read-only file
  109.     zsys    A system file
  110.  
  111.   Later, the “bundle” describes how to integrate file type(s) into your finished application.
  112.  
  113.  
  114.  
  115.  
  116.  
  117. Signature (the Creator code)
  118. ````````````````````````````
  119.   Each application must have a unique, four character signature.  A signature is often called a creator code because it answers the question “who created me” for every document on a Macintosh (an application is considered to be its own creator).  Your application’s signature will be used as the creator code for all the documents it creates.
  120.  
  121.   The Finder makes an association between each application and its related documents by using the application’s signature.  When a document is opened by the Finder, it knows which application created the file and automatically launches that application.
  122.  
  123.   Notice that some file types can be opened by several applications.  If you double-click a ‘TEXT’ file, it will be opened by the application that launched it (because the Finder recognizes the creator for the file is identical to the parent application’s signature).  However, just about any word processor can open a ‘TEXT’.
  124.  
  125.   In THINK Pascal, you set your application’s type and creator by using the Project menu’s “Set project Type” command.  Later, the “bundle” describes how to integrate the signature into your finished application.
  126.  
  127.  
  128. Note: Apple reserves the use of all file types and signatures (creator
  129.       codes) whose names contain only lowercase letters, and those that
  130.       contain only non-alphabetic characters.  Your file types and
  131.       signatures must contain at least one uppercase letter.  Since the
  132.       system software never displays the file type or signature to
  133.       users, these codes don’t have to be meaningful to anyone but you.
  134.          All file types and signatures must be registered with Apple to
  135.       guarantee uniqueness and prevent conflicts between applications.
  136.  
  137. Warning: When deciding upon a signature for your application, be careful
  138.          to avoid signatures that are identical to any existing resource
  139.          type, such as ‘ICON’ or ‘STR ’.  An owner resource must be
  140.          created with a type that matches your application’s signature,
  141.          and if it coincides with existing resources types, conflicts
  142.          may arise.  For a comprehensive list of resource codes, please
  143.          refer to the ResEdit Reference manual, or contact Apple.
  144.  
  145.  
  146.  
  147.  
  148.  
  149. Bundle
  150. ``````
  151.   The BNDL resource, which is simply called the “bundle,” is used to “bundle up” several related resources that are needed to define the association between your application, its documents, and the icons displayed by the Finder.  If you use ResEdit to create the BNDL resource, you will be presented with a template that lets you create and maintain the BNDL resource.
  152.  
  153.   Enter the four character signature you have selected for your application.
  154.  
  155.   Next, use the Resource menu’s “Create New File Type” command to create a new line.  Enter the file type.  Note that the first line should have a type of ‘APPL’ (application).  Double-click its “Finder Icons” section and you will be presented with a list of icons that you created earlier in the “Application Icons” section of this chapter.  Select the icon you want to use to represent the specified file type.  Repeat this for each file type that is supported by your application.
  156.  
  157.   The last thing you must do to complete the bundle is to set the “bundle bit.”  The bundle bit tells the Finder that your application has a bundle present.  In THINK Pascal, you set the bundle bit by using the Project menu’s “Set project Type” command, then building your application.  The bundle bit is set automatically in THINK C/C++ and Metrowerks compilers.
  158.  
  159.   When creating the BNDL resource, ResEdit automatically creates several other supporting resources.  One FREF resource (Finder REFerence) is created for each file type.  An “Owner Resource” is also created (ID=0).  Its resource type matches your application’s signature.  The owner resource is essentially a string resource that lets you enter a comment that is displayed as version information in the Finder’s “Get Info” box (providing you don’t create ‘vers’ resources).
  160.  
  161.  
  162. Note: If you change your application’s icons, you will have to rebuild
  163.       the desk top file to force the Finder to use your new icons.  To
  164.       rebuild the desk top, restart your Macintosh while holding the
  165.       option and command keys down, and continue to hold them until you
  166.       see a dialog that asks you if you want to rebuild your desk top.
  167.       Click the OK button to start rebuilding.
  168.          A similar problem sometimes occurs when an application is
  169.       copied to a disk using an installer or decompression program.
  170.       These kinds of programs may not have the intelligence to update
  171.       the desk top file like the Macintosh’s Finder does.
  172.  
  173.  
  174.  
  175.  
  176.  
  177. Version
  178. ```````
  179.   Your application can display some descriptive information in the Finder’s “Get Info” box by having ‘vers’ resources.  The two vers resources you can include in your applications are:
  180.  
  181.    ID=1  Application version number (i.e. 2.5, ©1994 - Water’s Edge
  182.          Software)
  183.  
  184.    ID=2  Application info displayed beneath the file name  (i.e., Tools
  185.          Plus Library (1 of 3) )
  186.  
  187. By using vers resources, any file can bear version information, including documents created by your application.
  188.  
  189.  
  190.  
  191.  
  192.  
  193. mstr Resources
  194. ``````````````
  195.   This section describes how System 5 and 6’s MultiFinder and System 7 automatically interact with your application’s menus if your application does not support high-level events (also called Apple Events).  You should set the appropriate bit in your application’s ‘SIZE’ resource to indicate if it supports Apple Events or not.
  196.  
  197.   Both MultiFinder (running under System 5 or 6) and System 7 can automatically interact with your application through its menus.  If your application is running while the user double-clicks (or select-opens) one of your application’s documents from the Finder, the affected document is automatically opened by your application.  Also, if the user selects the Special menu’s Restart or Shut Down command while your application is running, it is instructed to quit.
  198.  
  199.   In both these cases, the system simulates the selection of a menu item.  Typically applications have a File menu with an item named “Open…” (including the ellipsis, the Option-; character), and the last item named “Quit”.  In the case of opening a document, PollSystem returns a doMenu event to your application indicating that the File menu’s “Open…” command was selected, in which case your application would do whatever is appropriate, like display an SFGetFile dialog to let the user choose which file to open.  The system fools your application into thinking that the double-clicked file was selected from an SFGetFile dialog (which is not actually displayed).  When the user selects Restart or Shut Down, PollSystem returns a doMenu event to your application indicating that the File menu’s “Quit” command was selected, in which case your application would do whatever is appropriate, such as asking if open documents should be saved before quitting.
  200.  
  201.   If your application does not [1] open files by using the File menu’s “Open…” command, or [2] quit by using the File menu’s “Quit” command, these functions can be remapped to other menu items by including ‘mstr’ resources in your application.  Each mstr resource is a Pascal string (byte-0 is the length byte) that tells the Macintosh which menu and menu item to use in place of the standard ones:
  202.  
  203.    mstr ID=100   Name of the menu containing the equivalent of the
  204.                  “Quit” command
  205.  
  206.    mstr ID=101   Name of the menu item that is the equivalent of the
  207.                  “Quit” command
  208.  
  209.    mstr ID=102   Name of the menu containing the equivalent of the
  210.                  “Open…” command
  211.  
  212.    mstr ID=103   Name of the menu item that is the equivalent of the
  213.                  “Open…” command
  214.  
  215.  
  216.  
  217.  
  218.  
  219. SIZE Resource
  220. `````````````
  221.   If your application is going to run under MultiFinder or System 7, it needs a SIZE resource.  ResEdit has a resource template for the SIZE resource, which lets you set various values in the resource to specify how your application behaves in a multi-tasking environment.
  222.  
  223.   You will create a single resource with an ID of -1, but be aware that the Macintosh may clone (make a duplicate with a possible minor variation) your SIZE resource in your stand-alone application under certain conditions.  This is described later.
  224.  
  225.   The SIZE resource is comprised of sixteen bits that can be set to a value of 0 or 1, and two long integers.  Tools Plus requires that some of these items be set to a specific value while others depend upon how you want your application to behave.  The table below details the SIZE resource.
  226.  
  227.  
  228.         Compulsory Setting \   / Recommended Setting
  229.                             \ /
  230. SIZE Template’s Field Name | | | Comments
  231. ===========================+=+=+========================================
  232. Save screen (obsolete)     |0|0| (obsolete)
  233. ---------------------------+-+-+----------------------------------------
  234. Accept suspend events      |1|1| 0 = doSuspend and doResume events are
  235.                            | | |     not reported to your application.
  236.                            | | | 1 = Your application receives a
  237.                            | | |     doSuspend event prior to being
  238.                            | | |     suspended, and a doResume event
  239.                            | | |     immediately after being activated.
  240. ---------------------------+-+-+----------------------------------------
  241.                            |0|0| (obsolete)
  242. ---------------------------+-+-+----------------------------------------
  243. Can background             | |1| 0 = When your application is suspended,
  244.                            | | |     it receives no processing time
  245.                            | | | 1 = When your application is suspended,
  246.                            | | |     it receives processing time in the
  247.                            | | |     way of doNothing events.
  248.                            | | | If “Accept suspend events” is set to 0,
  249.                            | | | this item must be set to 1.
  250. ---------------------------+-+-+----------------------------------------
  251. Does activate on FG switch |1|1| 0 = The Macintosh’s operating system
  252.                            | | |     takes care of activating and
  253.                            | | |     deactivating a window when the
  254.                            | | |     application is suspended or
  255.                            | | |     resumed.
  256.                            | | | 1 = Your application takes care of
  257.                            | | |     activating or deactivating its
  258.                            | | |     windows in response to a doSuspend
  259.                            | | |     or doResume event (automatic in
  260.                            | | |     Tools Plus).
  261.                            | | | This item must have the same setting as
  262.                            | | | “Accept suspend events.”
  263. ---------------------------+-+-+----------------------------------------
  264. Only background            |0|0| 0 = Your application is a regular
  265.                            | | |     application.
  266.                            | | | 1 = Your application runs only in the
  267.                            | | |     background.  Usually, this is
  268.                            | | |     because it doesn’t have a user
  269.                            | | |     interface and cannot run in the
  270.                            | | |     foreground.
  271. ---------------------------+-+-+----------------------------------------
  272. Get front clicks           | |0| 0 = Your application does not receive
  273.                            | | |     the mouse-down used to activate it
  274.                            | | |     after being suspended.  Most
  275.                            | | |     applications work this way.
  276.                            | | | 1 = The mouse-down that activates your
  277.                            | | |     application is applied to your
  278.                            | | |     application.  This may mean that a
  279.                            | | |     button is selected, drawing begins,
  280.                            | | |     or an insertion point is set.  The
  281.                            | | |     Finder works in this manner.
  282. ---------------------------+-+-+----------------------------------------
  283. Accept app died events     | |0| 0 = ApplicationDied events are not
  284. (debuggers)                | | |     generated
  285.                            | | | 1 = Your application is notified (via
  286.                            | | |     an ApplicationDied event) when an
  287.                            | | |     application or process launched by
  288.                            | | |     your application has terminated or
  289.                            | | |     has crashed.  Read about System 7’s
  290.                            | | |     Process Manager for more details.
  291. ---------------------------+-+-+----------------------------------------
  292. 32 bit compatible          | |1| 0 = Your application is not 32-bit
  293.                            | | |     compatible
  294.                            | | | 1 = Your application can be run with
  295.                            | | |     the 32-bit Memory Manager.
  296.                            | | | Modern Mac compiler’s generate 32-bit
  297.                            | | | compatible code, so your app is 32-bit
  298.                            | | | clean providing you do not modify your
  299.                            | | | application’s addressing.
  300. ---------------------------+-+-+----------------------------------------
  301. High level event aware     | |0| 0 = No high-level events are received
  302.                            | | |     or sent by your application
  303.                            | | | 1 = Your application can receive and
  304.                            | | |     send high-level events (System 7)
  305.                            | | | If this item is set to 0, MultiFinder
  306.                            | | | and System 7 will automatically
  307.                            | | | interact with your application’s menus.
  308.                            | | | See the “Menus” chapter for details.
  309. ---------------------------+-+-+----------------------------------------
  310. Local and remote high      | |0| 0 = Your application cannot be
  311.  level events              | | |     accessed by applications running on
  312.                            | | |     other computers on a network.
  313.                            | | | 1 = Your application is accessible by
  314.                            | | |     applications running on other
  315.                            | | |     computers on a network, and it can
  316.                            | | |     receive high-level events across a
  317.                            | | |     network (System 7).
  318. ---------------------------+-+-+----------------------------------------
  319. Stationery aware           | |0| 0 = If the user opens a stationary
  320.                            | | |     document (System 7), the Finder
  321.                            | | |     makes a copy of the file and asks
  322.                            | | |     the user to name the copy.
  323.                            | | | 1 = Your application knows how to work
  324.                            | | |     with stationery documents
  325.                            | | |     (System 7)
  326. ---------------------------+-+-+----------------------------------------
  327. Use text edit services     | |0| 0 = Your application does not use
  328.                            | | |     inline TextEdit services
  329.                            | | | 1 = Your application uses inline
  330.                            | | |     TextEdit services (System 7).
  331.                            | | | Tools Plus’s editing fields don’t use
  332.                            | | | inline TextEdit services.  Set this
  333.                            | | | item to 1 only if you have designed
  334.                            | | | your own editing fields that use these
  335.                            | | | services.
  336. ---------------------------+-+-+----------------------------------------
  337. Reserved bit               |0|0| (reserved for future use)
  338. ---------------------------+-+-+----------------------------------------
  339. Reserved bit               |0|0| (reserved for future use)
  340. ---------------------------+-+-+----------------------------------------
  341. Reserved bit               |0|0| (reserved for future use)
  342. ---------------------------+-+-+----------------------------------------
  343. Size                       | | | The memory size at which your
  344.                            | | | application can run most efficiently.
  345.                            | | | When your application is launched, the
  346.                            | | | Operating System tries to secure this
  347.                            | | | amount of memory.
  348. ---------------------------+-+-+----------------------------------------
  349. Min size                   | | | The memory limit below which your
  350.                            | | | application will not run.
  351. ---------------------------+-+-+----------------------------------------
  352.  
  353.  
  354.  
  355.  
  356.  
  357. Cloned SIZE resources
  358. `````````````````````
  359.   Although you need to create only one SIZE resource (ID=-1), the Macintosh may make clones of it when the user makes changes in the Finder’s “Get Info” box.  When the user makes changes in the “Get Info” box, the Macintosh clones (makes a copy of the SIZE resource with ID=-1) and lets the user makes changes to the “Size” and “Min size” fields of the clone.  You only need to be concerned with this if you want to preset your application’s memory requirements to something other than the recommended limits defined by your original SIZE resource.
  360.  
  361.   The table below describes the contents of the “Size” and “Min size” fields for the original SIZE resource, as well as any clones that may be created by the Macintosh.
  362.  
  363.  
  364. ===========+====+=========+================+============================
  365. System File|SIZE| Field’s | Title in       |
  366.   Version  | ID |  Name   | “Get Info” box | Contents
  367. ===========+====+=========+================+============================
  368. 5 to 7.0.x | -1 |Size     |Application     | Memory required for optimum
  369.            |    |         |memory size     | performance
  370.            |    +---------+----------------+----------------------------
  371.            |    |Min size |Suggested memory| Memory limit below which
  372.            |    |         |size            | your application won’t run
  373.            +----+---------+----------------+----------------------------
  374.            | 0  |Size     |Application     | User’s setting
  375.            |    |         |memory size     |
  376.            |    +---------+----------------+----------------------------
  377.            |    |Min size |Suggested memory| Memory limit below which
  378.            |    |         |size            | your application won’t run
  379.            |    |         |                | (same as ID=-1)
  380. -----------+----+---------+----------------+----------------------------
  381. 7.1 or     | -1 |Size     |Suggested size  | Memory required for optimum
  382. higher     |    |         |                | performance
  383.            |    +---------+----------------+----------------------------
  384.            |    |Min size |(not displayed) | Memory limit below which
  385.            |    |         |                | your application won’t run
  386.            +----+---------+----------------+----------------------------
  387.            | 0  |Size     |Preferred size  | User’s preferred memory
  388.            |    |         |                | allowance
  389.            |    +---------+----------------+----------------------------
  390.            |    |Min size |(not displayed) | Memory limit below which
  391.            |    |         |                | your application won’t run
  392.            |    |         |                | (same as ID=-1)
  393.            +----+---------+----------------+----------------------------
  394.            | 1  |Size     |(not displayed) | User’s preferred memory
  395.            |    |         |                | allowance
  396.            |    |         |                | (same as ID=0)
  397.            |    +---------+----------------+----------------------------
  398.            |    |Min size |Minimum size    | User’s minimum memory
  399.            |    |         |                | allowance below which the
  400.            |    |         |                | application won’t run.
  401. -----------+----+---------+----------------+----------------------------
  402.